<!DOCTYPE html>
<html lang="si">
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta name="description" content="මෙම අත්හදා බැලීම අංක ගණිතමය එකතු කිරීමේ කාර්යය මත සාපේක්ෂ දුර (ROPER) සහිත රොටරි ස්ථානීය කාවැද්දීම් සහිත ට්රාන්ස්ෆෝමර් ආකෘතියක් පුහුණු කරයි."/>

    <meta name="twitter:card" content="summary"/>
    <meta name="twitter:image:src" content="https://avatars1.githubusercontent.com/u/64068543?s=400&amp;v=4"/>
    <meta name="twitter:title" content="සාපේක්ෂ දුර (ROPER) අත්හදා බැලීම සහිත රොටරි ස්ථානීය කාවැද්දීම්"/>
    <meta name="twitter:description" content="මෙම අත්හදා බැලීම අංක ගණිතමය එකතු කිරීමේ කාර්යය මත සාපේක්ෂ දුර (ROPER) සහිත රොටරි ස්ථානීය කාවැද්දීම් සහිත ට්රාන්ස්ෆෝමර් ආකෘතියක් පුහුණු කරයි."/>
    <meta name="twitter:site" content="@labmlai"/>
    <meta name="twitter:creator" content="@labmlai"/>

    <meta property="og:url" content="https://nn.labml.ai/transformers/rope/value_pe/arithmetic_experiment.html"/>
    <meta property="og:title" content="සාපේක්ෂ දුර (ROPER) අත්හදා බැලීම සහිත රොටරි ස්ථානීය කාවැද්දීම්"/>
    <meta property="og:image" content="https://avatars1.githubusercontent.com/u/64068543?s=400&amp;v=4"/>
    <meta property="og:site_name" content="සාපේක්ෂ දුර (ROPER) අත්හදා බැලීම සහිත රොටරි ස්ථානීය කාවැද්දීම්"/>
    <meta property="og:type" content="object"/>
    <meta property="og:title" content="සාපේක්ෂ දුර (ROPER) අත්හදා බැලීම සහිත රොටරි ස්ථානීය කාවැද්දීම්"/>
    <meta property="og:description" content="මෙම අත්හදා බැලීම අංක ගණිතමය එකතු කිරීමේ කාර්යය මත සාපේක්ෂ දුර (ROPER) සහිත රොටරි ස්ථානීය කාවැද්දීම් සහිත ට්රාන්ස්ෆෝමර් ආකෘතියක් පුහුණු කරයි."/>

    <title>සාපේක්ෂ දුර (ROPER) අත්හදා බැලීම සහිත රොටරි ස්ථානීය කාවැද්දීම්</title>
    <link rel="shortcut icon" href="/icon.png"/>
    <link rel="stylesheet" href="../../../pylit.css?v=1">
    <link rel="canonical" href="https://nn.labml.ai/transformers/rope/value_pe/arithmetic_experiment.html"/>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.13.18/dist/katex.min.css" integrity="sha384-zTROYFVGOfTw7JV7KUu8udsvW2fx4lWOsCEDqhBreBwlHI4ioVRtmIvEThzJHGET" crossorigin="anonymous">

    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-4V3HC8HBLH"></script>
    <script>
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }

        gtag('js', new Date());

        gtag('config', 'G-4V3HC8HBLH');
    </script>
</head>
<body>
<div id='container'>
    <div id="background"></div>
    <div class='section'>
        <div class='docs'>
            <p>
                <a class="parent" href="/">home</a>
                <a class="parent" href="../../index.html">transformers</a>
                <a class="parent" href="../index.html">rope</a>
                <a class="parent" href="index.html">value_pe</a>
            </p>
            <p>
                <a href="https://github.com/labmlai/annotated_deep_learning_paper_implementations" target="_blank">
                    <img alt="Github"
                         src="https://img.shields.io/github/stars/labmlai/annotated_deep_learning_paper_implementations?style=social"
                         style="max-width:100%;"/></a>
                <a href="https://twitter.com/labmlai" rel="nofollow" target="_blank">
                    <img alt="Twitter"
                         src="https://img.shields.io/twitter/follow/labmlai?style=social"
                         style="max-width:100%;"/></a>
            </p>
            <p>
                <a href="https://github.com/labmlai/annotated_deep_learning_paper_implementations/tree/master/labml_nn/transformers/rope/value_pe/arithmetic_experiment.py" target="_blank">
                    View code on Github</a>
            </p>
        </div>
    </div>
    <div class='section' id='section-0'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-0'>#</a>
            </div>
            <h1>සාපේක්ෂදුර (<a href="index.html">ROPER</a>) අත්හදා බැලීම සහිත රොටරි ස්ථානීය කාවැද්දීම්</h1>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">11</span><span></span><span class="kn">from</span> <span class="nn">labml</span> <span class="kn">import</span> <span class="n">experiment</span>
<span class="lineno">12</span><span class="kn">from</span> <span class="nn">labml.configs</span> <span class="kn">import</span> <span class="n">calculate</span>
<span class="lineno">13</span><span class="kn">from</span> <span class="nn">labml_nn.experiments.arithmetic_dataset</span> <span class="kn">import</span> <span class="n">ArithmeticAutoregression</span>
<span class="lineno">14</span><span class="kn">from</span> <span class="nn">labml_nn.transformers</span> <span class="kn">import</span> <span class="n">TransformerConfigs</span>
<span class="lineno">15</span><span class="kn">from</span> <span class="nn">labml_nn.transformers.rope.experiment</span> <span class="kn">import</span> <span class="n">Configs</span> <span class="k">as</span> <span class="n">RoPEConfigs</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-1'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-1'>#</a>
            </div>
            <p> අපි <a href="../experiment.html">කඹය අත්හදා</a> උරුම කර <a href="../../experiments/arithmetic_dataset.html">අංක ගණිතමය එකතු කිරීමේ කාර්යය</a> සඳහා එය භාවිතා කරමු. </p>
<p>අපිපහත සාපේක්ෂ දුර (ROPER) සමග රොටරි ස්ථානීය කාවැද්දීම් භාවිතා කිරීමට අවධානය වෙනස් කිරීමට විකල්පය එකතු කරන්න. </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">18</span><span class="k">class</span> <span class="nc">Configs</span><span class="p">(</span><span class="n">RoPEConfigs</span><span class="p">,</span> <span class="n">ArithmeticAutoregression</span><span class="p">):</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-2'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-2'>#</a>
            </div>
            
        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">26</span>    <span class="k">pass</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-3'>
        <div class='docs doc-strings'>
            <div class='section-link'>
                <a href='#section-3'>#</a>
            </div>
            <p> අවධානයයොමු කිරීමේදී සාපේක්ෂ දුර (<a href="index.html">ROPER</a>) සහිත රොටරි ස්ථානීය කාවැද්දීම් භාවිතා කරන්න. </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">29</span><span class="k">def</span> <span class="nf">_rotary_value_pe_mha</span><span class="p">(</span><span class="n">c</span><span class="p">:</span> <span class="n">TransformerConfigs</span><span class="p">):</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-4'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-4'>#</a>
            </div>
            
        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">33</span>    <span class="kn">from</span> <span class="nn">labml_nn.transformers.rope.value_pe</span> <span class="kn">import</span> <span class="n">RotaryValuePEMultiHeadAttention</span>
<span class="lineno">34</span>    <span class="k">return</span> <span class="n">RotaryValuePEMultiHeadAttention</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">n_heads</span><span class="p">,</span> <span class="n">c</span><span class="o">.</span><span class="n">d_model</span><span class="p">,</span> <span class="mf">1.</span><span class="p">,</span> <span class="mf">1.</span><span class="p">)</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-5'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-5'>#</a>
            </div>
            <p>වින්යාසවිකල්ප </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">38</span><span class="n">calculate</span><span class="p">(</span><span class="n">TransformerConfigs</span><span class="o">.</span><span class="n">encoder_attn</span><span class="p">,</span> <span class="s1">&#39;rotary_value&#39;</span><span class="p">,</span> <span class="n">_rotary_value_pe_mha</span><span class="p">)</span>
<span class="lineno">39</span><span class="n">calculate</span><span class="p">(</span><span class="n">TransformerConfigs</span><span class="o">.</span><span class="n">decoder_attn</span><span class="p">,</span> <span class="s1">&#39;rotary_value&#39;</span><span class="p">,</span> <span class="n">_rotary_value_pe_mha</span><span class="p">)</span>
<span class="lineno">40</span><span class="n">calculate</span><span class="p">(</span><span class="n">TransformerConfigs</span><span class="o">.</span><span class="n">decoder_mem_attn</span><span class="p">,</span> <span class="s1">&#39;rotary_value&#39;</span><span class="p">,</span> <span class="n">_rotary_value_pe_mha</span><span class="p">)</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-6'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-6'>#</a>
            </div>
            
        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">43</span><span class="k">def</span> <span class="nf">main</span><span class="p">():</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-7'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-7'>#</a>
            </div>
            <p>අත්හදාබැලීම සාදන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">45</span>    <span class="n">experiment</span><span class="o">.</span><span class="n">create</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">&quot;roper_addition&quot;</span><span class="p">,</span> <span class="n">comment</span><span class="o">=</span><span class="s2">&quot;rotary value 7&quot;</span><span class="p">,</span> <span class="n">writers</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;screen&#39;</span><span class="p">,</span> <span class="s1">&#39;labml&#39;</span><span class="p">})</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-8'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-8'>#</a>
            </div>
            <p>වින්යාසසාදන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">47</span>    <span class="n">conf</span> <span class="o">=</span> <span class="n">Configs</span><span class="p">()</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-9'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-9'>#</a>
            </div>
            <p>වින්යාසයන්අභිබවා යන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">49</span>    <span class="n">experiment</span><span class="o">.</span><span class="n">configs</span><span class="p">(</span><span class="n">conf</span><span class="p">,</span> <span class="p">{</span>
<span class="lineno">50</span>        <span class="s1">&#39;max_digits&#39;</span><span class="p">:</span> <span class="mi">7</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-10'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-10'>#</a>
            </div>
            <p>ස්ථාවරස්ථානීය කාවැද්දීම් නොමැත </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">53</span>        <span class="s1">&#39;transformer.src_embed&#39;</span><span class="p">:</span> <span class="s1">&#39;no_pos&#39;</span><span class="p">,</span>
<span class="lineno">54</span>        <span class="s1">&#39;transformer.tgt_embed&#39;</span><span class="p">:</span> <span class="s1">&#39;no_pos&#39;</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-11'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-11'>#</a>
            </div>
            <p>ROPERඅවධානය සහිත එන්කෝඩරය </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">57</span>        <span class="s1">&#39;transformer.encoder_attn&#39;</span><span class="p">:</span> <span class="s1">&#39;rotary_value&#39;</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-12'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-12'>#</a>
            </div>
            <p>කඹයඅවධානය සහිත එන්කෝඩරය 'transformer.encoder_attn': 'භ්රමණය', </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre></pre></div>
        </div>
    </div>
    <div class='section' id='section-13'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-13'>#</a>
            </div>
            <p> </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">62</span>        <span class="s1">&#39;model&#39;</span><span class="p">:</span> <span class="s1">&#39;rotary_pe_transformer&#39;</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-14'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-14'>#</a>
            </div>
            <p>කසන්දර්භය ප්රමාණය භාවිතා <span ><span class="katex"><span aria-hidden="true" class="katex-html"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">256</span></span></span></span></span> </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">65</span>        <span class="s1">&#39;seq_len&#39;</span><span class="p">:</span> <span class="mi">512</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-15'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-15'>#</a>
            </div>
            <p>32වයස අවුරුදු සඳහා දුම්රිය </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">67</span>        <span class="s1">&#39;epochs&#39;</span><span class="p">:</span> <span class="mi">20</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-16'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-16'>#</a>
            </div>
            <p>කණ්ඩායම්ප්රමාණය <span ><span class="katex"><span aria-hidden="true" class="katex-html"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">4</span></span></span></span></span> </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">69</span>        <span class="s1">&#39;batch_size&#39;</span><span class="p">:</span> <span class="mi">16</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-17'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-17'>#</a>
            </div>
            <p>ආදර්ශප්රමාණය </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">72</span>        <span class="s1">&#39;d_model&#39;</span><span class="p">:</span> <span class="mi">128</span><span class="p">,</span>
<span class="lineno">73</span>        <span class="s1">&#39;transformer.ffn.d_ff&#39;</span><span class="p">:</span> <span class="mi">512</span><span class="p">,</span>
<span class="lineno">74</span>        <span class="s1">&#39;transformer.n_heads&#39;</span><span class="p">:</span> <span class="mi">4</span><span class="p">,</span>
<span class="lineno">75</span>        <span class="s1">&#39;transformer.dropout&#39;</span><span class="p">:</span> <span class="mf">0.0</span><span class="p">,</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-18'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-18'>#</a>
            </div>
            <p><a href="../../optimizers/noam.html">ආදම් ප්රශස්තකරණය</a> භාවිතා </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">78</span>        <span class="s1">&#39;optimizer.optimizer&#39;</span><span class="p">:</span> <span class="s1">&#39;Adam&#39;</span><span class="p">,</span>
<span class="lineno">79</span>        <span class="s1">&#39;optimizer.learning_rate&#39;</span><span class="p">:</span> <span class="mf">2.5e-4</span><span class="p">,</span>
<span class="lineno">80</span>    <span class="p">})</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-19'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-19'>#</a>
            </div>
            <p>ඉතිරිකිරීම සහ පැටවීම සඳහා ආකෘති සකසන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">83</span>    <span class="n">experiment</span><span class="o">.</span><span class="n">add_pytorch_models</span><span class="p">({</span><span class="s1">&#39;model&#39;</span><span class="p">:</span> <span class="n">conf</span><span class="o">.</span><span class="n">model</span><span class="p">})</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-20'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-20'>#</a>
            </div>
            <p>අත්හදාබැලීම ආරම්භ කරන්න </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">86</span>    <span class="k">with</span> <span class="n">experiment</span><span class="o">.</span><span class="n">start</span><span class="p">():</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-21'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-21'>#</a>
            </div>
            <p>පුහුණුධාවනය </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">88</span>        <span class="n">conf</span><span class="o">.</span><span class="n">run</span><span class="p">()</span></pre></div>
        </div>
    </div>
    <div class='section' id='section-22'>
        <div class='docs'>
            <div class='section-link'>
                <a href='#section-22'>#</a>
            </div>
            <p> </p>

        </div>
        <div class='code'>
            <div class="highlight"><pre><span class="lineno">92</span><span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s1">&#39;__main__&#39;</span><span class="p">:</span>
<span class="lineno">93</span>    <span class="n">main</span><span class="p">()</span></pre></div>
        </div>
    </div>
    <div class='footer'>
        <a href="https://papers.labml.ai">Trending Research Papers</a>
        <a href="https://labml.ai">labml.ai</a>
    </div>
</div>
<script src=../../../interactive.js?v=1"></script>
<script>
    function handleImages() {
        var images = document.querySelectorAll('p>img')

        for (var i = 0; i < images.length; ++i) {
            handleImage(images[i])
        }
    }

    function handleImage(img) {
        img.parentElement.style.textAlign = 'center'

        var modal = document.createElement('div')
        modal.id = 'modal'

        var modalContent = document.createElement('div')
        modal.appendChild(modalContent)

        var modalImage = document.createElement('img')
        modalContent.appendChild(modalImage)

        var span = document.createElement('span')
        span.classList.add('close')
        span.textContent = 'x'
        modal.appendChild(span)

        img.onclick = function () {
            console.log('clicked')
            document.body.appendChild(modal)
            modalImage.src = img.src
        }

        span.onclick = function () {
            document.body.removeChild(modal)
        }
    }

    handleImages()
</script>
</body>
</html>